#include "Mydict.h"
#include "SpellcorrectServer.h"
#include "CacheManager.h"
#include "Cache.h"
#include "Timer.hpp"
#include "Thread.hpp"
#include <iostream>

void test()
{
    CacheManager::initCache(4,"ceshi.txt");//缓存文件
    unique_ptr<xkk::Timer> timer(new xkk::Timer(
          CacheManager::periodicUpdateCaches,3,5 ));

    unique_ptr<xkk::Thread> timerThread(new xkk::Thread(
          bind(&xkk::Timer::start,timer.get())));
    
    timerThread->start();

    Mydict::createInstance()->init(
        "../../part1/dictionary/dict_en.txt","../../part1/dictionary/dict_cn.txt");
    //词典文件
    SpellcorrectServer spell("测试.txt");//配置文件
    spell.start();

    Mydict::createInstance()->destroy();
}

void test1()
{
    CacheManager::initCache(4,"ceshi.txt");
    for(auto&elem:CacheManager::getCache(0).getLRUlist())
    {
        cout<<elem.first<<" : "<<elem.second<<endl;
    }

}
int main()
{
    test();
    return 0;
}
